﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Imaginarium.team;

namespace Imaginarium.battleSistem
{
    public class SubjectCharacterStat
    {
        private HashSet<IOnCharacterAffected> charAffectedListeners = new HashSet<IOnCharacterAffected>();

        #region SingletonPattern
        private static SubjectCharacterStat instance;
        private SubjectCharacterStat() { }
        public static SubjectCharacterStat getInstance()
        {
            if(instance==null)
                instance = new SubjectCharacterStat();
            return instance;
        }
        #endregion

        #region Functionality
        public void addCharAffectedListener(IOnCharacterAffected listener) 
        {
            charAffectedListeners.Add(listener);
        }
        public bool removeCharAffectedListener(IOnCharacterAffected listener) 
        {
            return charAffectedListeners.Remove(listener);
        }
        public void charAffected(Character character) 
        {
            foreach (IOnCharacterAffected listener in charAffectedListeners) 
            {
                listener.onCharacterAffected(character);
            }
        }
        #endregion
    }
}
